<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!doctype html>
<html>
	<head>
		<title>玩家资源修改日志</title>
		<base href="<%=basePath%>" />
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="stylesheet" href="layui/css/layui.css" media="all"> <!-- 适应所有设备 -->
		<style type="text/css">
		</style>
	</head>
	<% String nowDay = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); %>
	<body>

		<br />
		<form class="layui-form" onsubmit='return false'>
			<!-- 返回所有玩家信息 -->
			<div class="layui-form-item">
				<div class="layui-input-inline">
					<input type="text" name="playerID" id="playerID" placeholder="玩家ID" autocomplete="off" class="layui-input">
				</div>
				
				<div class="layui-input-inline">
					<select name="ResourceType" id="ResourceType" lay-filter="ResourceType">
					    <option value="0">全部</option>
					    <option value="1">玩家携带资源</option>
					    <option value="2">玩家金库</option>
					</select>
				</div>
			
				<div class="layui-inline">
					<div class="layui-input-inline">
						<button class="layui-btn layui-btn-normal" data-type="reload" lay-filter="SelectOrder"
							id="SelectOrder" onsubmit='return false'>搜索</button>
					</div>
				</div>
			</div>
		</form>
		
		<table lay-filter="ResourceLog" id="ResourceLog" class="layui-table"/>
		
		<script src="js/jquery.min.js"></script>
		<script src="layui/layui.js" charset="utf-8"></script>
		<script  type="text/html" id="Type">
            {{#  if(d.ResourceType == 1){ }}
               <span>玩家携带资源</span>
            {{#  } else if (d.ResourceType == 2){ }}
               <span>玩家金库</span>
            {{#  } }}
        </script>
		
        <script>
			layui.use(['form', 'layer', 'table'], function() {
			var form = layui.form;
			var layer = layui.layer;
			var table = layui.table;

				layer.config({
					extend: 'MySkin/style.css'
				});
				/* table.init('PlayerShow'); */
				
            var tableIns = table.render({
					elem:'#ResourceLog',
					url:'player/UpdatePlayerResourceLog',
					method:'post',
					title:'玩家资源修改日志',
					even:true,
					id:'AllTable',
					request:{
						pageName:'pageIndex',
						limitName:'pageCount'
					},
					page:{
						limit: 30,
						limits: [10, 20, 30, 40, 50],
					},
					where:{
						UserId : $('#playerID').val(),
						ResourceType : $('#ResourceType').val()
					},
					cols:[[
						{field:'UserId',title:'ID'},
						{field:'Nickname',title:'昵称'},
						{field:'ResourceType',title:'资源类型',templet:'#Type',style:'color:red'},
						{field:'ItemName',title:'物品名称'},
						{field:'Delta',title:'改变量'},
						{field:'AffectAmount',title:'实际影响的数量'},
						{field:'Operater',title:'操作的管理员'},
						{field:'CreateTime',title:'操作时间'}
						]],
						response:{
							statusCode : 200
						},
						parseData:function(res){
							return{
								"code":res.status,
								"msg":res.message,
								"count":res.count,
								"data":res.data
							};
						}
				});
	          //表格重载
				var active = {
					reload:function(){
						table.reload('AllTable',{
							page:{
								cuur:1
							},
							where:{
								UserId : $('#playerID').val(),
								ResourceType : $('#ResourceType').val()
							}
						});
						return false;
					}
				};
				//点击搜索按钮根据用户名称查询
				  $('#SelectOrder').on('click',
			        function(){
			            var type = $(this).data('type');
			            active[type] ? active[type].call(this) : '';
			        });
				
				//按照当前的状态重载
				setInterval(function(){
	              	table.reload('AllTable', {});
	              },60000);
			});
			</script>
		</body>
	</html>
				